<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>设置/修改提现密码</title>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/own.css"/>
    <script type="text/javascript" src="../../js/mui.min.js" ></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <script>
    	mui.init({
//		    subpages:[{
//		      url:'../commonback.html',
//		      id:'common.html',
//		      styles:{
//		        top:'0px',//mui标题栏默认高度为45px；
//		      }
//		    }]
		  });  
		  var user_mobile=null;
		  mui.plusReady(function(){
		  	//初始化监听头部和底部事件
			tzdr.init.initHearListener();
		  	//获取手机号码
		  	user_mobile=mui.cacheUser.get("user_mobile");
		  	if(mui.isnull(user_mobile)){
		  		mui.toast("请重新登录");
		  		mui.openWindow("../login/login.html");
		  	}
		  	document.getElementById("mobile").innerHTML=user_mobile;
		  	
		  	document.getElementById("code").addEventListener("tap",function(){
		  		var o=document.getElementById("code");
		  		tzdr.smsTime(o); 
		  		getCode();
		  	});
		  	
		  	document.getElementById("drawpwset").addEventListener("tap",function(){
		  		drawpwSet();
		  	});
		  	
		  });
		  //设置提现密码
		  function drawpwSet(){
		  	var code=document.getElementById("password").value;
		  	var password=document.getElementById("password_confirm").value;
		  	var password2=document.getElementById("email").value;
		  	var paramUrl={
						url:"../login/login.html"
					}
		  	if(mui.isnull(code)){
		  		mui.toast("验证码不能为空");
		  		return;
		  	}
		  	
		  	if(!tzdr.validate_password(password)){
		  		mui.toast("密码必须由6-16位数字和字母组成");
		  		return;
		  	}
		  	if(mui.isnull(password2)){
		  		mui.toast("确认密码不能为空！");
		  		return;
		  	}
		  	if(password!=password2){
		  		mui.toast("两次密码输入不一致");
		  		return;
		  	}
		  	mui.app_request("user/security/set_withdraw_pwd",{
		  		 "code":code,
    			"password":password
		  	},function(result){
		  		mui.toast("设置成功！");
		  		mui.app_refresh("withdraw");
		  		return;
		  	},function(result){
		  		if(result.code==2){
		  			mui.toast("设置失败");
		  			return;
		  		}else if(result.code==3){
		  			mui.toast("用户信息不存在");
		  			return;
		  		}else if(result.code==4){
		  			mui.toast("提款密码不能与登录密码相同");
		  			return;
		  		}else if(result.code==5){
		  			mui.toast("密码格式有误");
		  			return;
		  		}else if(result.code==6){
		  			mui.toast("验证码错误或失效");
		  			return;
		  		}
		  	},paramUrl)
		  	
		  	
		  };
		  
		  
		  //获取短信验证码
		  function getCode(){
		  	var mobile=document.getElementById("mobile").innerHTML;
		  	var paramUrl={
						url:"../login/login.html"
					}
		 	if(!tzdr.validate_mobile(mobile)||mui.isnull(mobile)){
    			mui.toast("手机号码不正确");
    			return;
    		}
		 	//发送验证码
		 	mui.app_request("user/security/send_sms",{
		 		"mobile":mobile,
				"type":2
		 	},function(result){
		 		mui.toast("发送成功！");	
		 		return;
		 	},function(result){
		 		if(result.code==2){
		 			mui.toast("短信验证码发送失败！");	
		 			return;
		 		}else if(result.code==3){
		 			mui.toast("手机号码已经存在！");	
		 			return;
		 		}else if(result.code==4){
		 			mui.toast("手机号码不存在！");	
		 			return;
		 		}else if(result.code==5){
		 			mui.toast("操作过于频繁，请稍候再试！");	
		 			return;
		 		}else{
		 			mui.toast("系统繁忙，请稍候再试！");	
		 			return;
		 		}
		 	},paramUrl)
		 	
		  };
    </script>
</head>
<body>
	<header class="mui-bar mui-bar-nav own-topbg">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="back"><i>返回</i></a>
		<h1 class="mui-title">设置/修改提现密码</h1>		
		<a href="javascript:void(0)" class="top-tel" id="online">在线客服</a>
	</header>
	<!--<nav class="navlist">
		<a href="javascript:void(0);" id="product">
			<span class="mui-icon mui-icon-list"></span>
			<span class="mui-tab-label">产品</span>
		</a>
		<a class="" href="javascript:void(0);"  id="scheme">
			<span class="mui-icon mui-icon-compose"></span>
			<span class="mui-tab-label">方案</span>
		</a>
		<a  class="navon"  id="account" href="javascript:void(0);">
			<span class="mui-icon mui-icon-contact mui-icon-icon-contact-filled"></span>
			<span class="mui-tab-label" >账户</span>
		</a>
	</nav>-->
<div class="mui-content ac_tel">
	<form class="mui-input-group" id="pwdForm">
		<div class="mui-input-row">
			<label>手机号码</label>
			<span id="mobile" class="awc_tel">18281001133</span>
		</div>
		<div class="mui-input-row">
			<label>短信验证</label>
			<input id='password' type="text" class="mui-input" placeholder="请输入验证码">
			<button class="lg_codebtn" id="code" type="button">获取验证码</button>
		</div>		
		<div class="mui-input-row">
			<label>设置新密码</label>
			<input id='password_confirm' type="password" class="mui-input-clear mui-input" placeholder="6-16位数字和字母组成">
		</div>
		<div class="mui-input-row">
			<label>确认新密码</label>
			<input id='email' type="password" class="mui-input-clear mui-input" placeholder="">
		</div>
	</form>	
	<div class="mui-content-padded">
		<button id="drawpwset" type="button" class="mui-btn mui-btn-block lg-btnlogin">确认</button>
	</div>
	</div>
</body>
<script>
	tzdr.online();
</script>
</html>